import Types from '../actionTypes';

import {
  getSelfBeforeLsit,
  getspecsLibraryData
} from '../../api';

const SPECS_SELECT = code => {
  return {
    type: Types.SPECS_SELECT,
    value: code
  };
};
const SPECS_IS_SELECT = value => {
  return {
    type: Types.SPECS_IS_SELECT,
    value
  };
};

const ACTIVE_KEY = value => {
  return {
    type: Types.ACTIVE_KEY,
    value
  };
};
const ACTIVE_TITLE = value => {
  return {
    type: Types.ACTIVE_TITLE,
    value
  };
};

const GET_SPECSLIBRARY_INFO = code => {
  return new Promise((resolve, reject) => {
    getspecsLibraryData(code)
      .then(res => {
        resolve({
          type: Types.GET_SPECSLIBRARY_INFO,
          data: res.data
        });
      }).catch(err => {
      console.log(err);
    });
  });
};


export default {
  SPECS_SELECT,
  SPECS_IS_SELECT,
  ACTIVE_KEY,
  ACTIVE_TITLE,
  GET_SPECSLIBRARY_INFO
};
